Imports Microsoft.VisualBasic
Imports System.Data.Common

Public Class MySqlConnection
    Inherits DbConnection

    Friend ReadOnly _conn As MySql.Data.MySqlClient.MySqlConnection

    Sub New()

        Me._conn = New MySql.Data.MySqlClient.MySqlConnection()

    End Sub

    Sub New(ByVal conn As MySql.Data.MySqlClient.MySqlConnection)

        Me._conn = conn

    End Sub

    Protected Overrides Function BeginDbTransaction(ByVal isolationLevel As System.Data.IsolationLevel) As System.Data.Common.DbTransaction

        Return New MySqlTransaction(_conn.BeginTransaction())

    End Function

    Public Overrides Sub ChangeDatabase(ByVal databaseName As String)

        Me._conn.ChangeDatabase(databaseName)

    End Sub

    Public Overrides Sub Close()

        Me._conn.Close()

    End Sub

    Public Overrides Property ConnectionString() As String
        Get
            Return Me._conn.ConnectionString
        End Get
        Set(ByVal value As String)
            Me._conn.ConnectionString = value
        End Set
    End Property

    Protected Overrides Function CreateDbCommand() As System.Data.Common.DbCommand

        Return New MySqlCommand(Me._conn.CreateCommand())

    End Function

    Public Overrides ReadOnly Property Database() As String
        Get
            Return Me._conn.Database
        End Get
    End Property

    Public Overrides ReadOnly Property DataSource() As String
        Get
            Return Me._conn.DataSource
        End Get
    End Property

    Public Overrides Sub Open()

        Me._conn.Open()

    End Sub

    Public Overrides ReadOnly Property ServerVersion() As String
        Get
            Return Me._conn.ServerVersion
        End Get
    End Property

    Public Overrides ReadOnly Property State() As System.Data.ConnectionState
        Get
            Return Me._conn.State
        End Get
    End Property
End Class
